<template>
  <div class="app-container">
    <el-form :model="queryParams" ref="queryRef" :inline="true" v-show="showSearch" label-width="68px">
      <el-form-item label="店铺名称" prop="name">
        <el-input v-model="queryParams.name" placeholder="请输入店铺名称" clearable @keyup.enter="handleQuery" />
      </el-form-item>
      <el-form-item label="手机号" prop="telephone">
        <el-input v-model="queryParams.telephone" placeholder="请输入手机号" clearable @keyup.enter="handleQuery" />
      </el-form-item>
      <el-form-item label="法人" prop="legalPerson">
        <el-input v-model="queryParams.legalPerson" placeholder="请输入法人" clearable @keyup.enter="handleQuery" />
      </el-form-item>
      <el-form-item label="用户ID" prop="uid">
        <el-input v-model="queryParams.uid" placeholder="请输入用户ID" clearable @keyup.enter="handleQuery" />
      </el-form-item>
      <el-form-item label="审核状态" prop="toExamine">
        <el-select v-model="queryParams.toExamine" clearable placeholder="请选择审核状态">
          <el-option label="待审核" :value="1"></el-option>
          <el-option label="审核成功" :value="2"></el-option>
          <el-option label="审核失败" :value="3"></el-option>
        </el-select>
      </el-form-item>
      <el-form-item label="分类ID" prop="classification">
        <el-input v-model="queryParams.classification" placeholder="请输入分类ID" clearable @keyup.enter="handleQuery" />
      </el-form-item>
      <el-form-item label="标签" prop="label">
        <el-input v-model="queryParams.label" placeholder="请输入标签" clearable @keyup.enter="handleQuery" />
      </el-form-item>
      <el-form-item label="评分等级" prop="grade">
        <el-select v-model="queryParams.grade" clearable placeholder="请选择评分等级">
          <el-option label="优" value="优">
          </el-option>
          <el-option label="良" value="良">
          </el-option>
          <el-option label="中" value="中">
          </el-option>
          <el-option label="及格" value="及格">
          </el-option>
        </el-select>
      </el-form-item>
      <el-form-item>
        <el-button type="primary" icon="Search" @click="handleQuery">搜索</el-button>
        <el-button icon="Refresh" @click="resetQuery">重置</el-button>
      </el-form-item>
    </el-form>

    <el-row :gutter="10" class="mb8">
      <el-col :span="1.5">
        <el-button type="primary" plain icon="Plus" @click="handleAdd" v-hasPermi="['ds:store:add']">新增</el-button>
      </el-col>
      <el-col :span="1.5">
        <el-button type="success" plain icon="Edit" :disabled="single" @click="handleUpdate"
          v-hasPermi="['ds:store:edit']">修改</el-button>
      </el-col>
      <el-col :span="1.5">
        <el-button type="danger" plain icon="Delete" :disabled="multiple" @click="handleDelete"
          v-hasPermi="['ds:store:remove']">删除</el-button>
      </el-col>
      <el-col :span="1.5">
        <el-button type="warning" plain icon="Download" @click="handleExport"
          v-hasPermi="['ds:store:export']">导出</el-button>
      </el-col>
      <right-toolbar v-model:showSearch="showSearch" @queryTable="getList"></right-toolbar>
    </el-row>

    <el-table v-loading="loading" :data="storeList" @selection-change="handleSelectionChange">
      <el-table-column type="selection" width="55" align="center" />
      <el-table-column label="ID" align="center" prop="id" />
      <el-table-column label="店铺名称" align="center" prop="name" />
      <el-table-column label="店铺图片" align="center" prop="picture">
        <template #default="scope">
          <el-image :src="scope.row.picture"></el-image>
        </template>
      </el-table-column>
      <!-- <el-table-column
        label="店铺简介"
        align="center"
        prop="details"
      /> -->
      <el-table-column label="手机号" align="center" prop="telephone" />
      <el-table-column label="法人" align="center" prop="legalPerson" />
      <!-- <el-table-column label="法人身份证正面" align="center" prop="frontIdCard" />
      <el-table-column label="法人身份证反面" align="center" prop="reverseIdCard" />
      <el-table-column label="用户ID" align="center" prop="uid" /> -->
      <el-table-column label="审核状态" align="center" prop="toExamine">
        <template #default="scope">
          <el-tag type="primary" v-if="scope.row.toExamine === 1">待审核</el-tag>
          <el-tag type="success" v-if="scope.row.toExamine === 2">已审核</el-tag>
          <el-tag type="danger" v-if="scope.row.toExamine === 3">审核失败</el-tag>
          <span v-if="scope.row.toExamine === 3">{{ scope.row.reason }}</span>
        </template>
      </el-table-column>
      <el-table-column label="状态" align="center" prop="status">
        <template #default="scope">
          <el-tag type="primary" v-if="scope.row.status === 1">正常</el-tag>
          <el-tag type="danger" v-if="scope.row.status === 2">删除</el-tag>
        </template>
      </el-table-column>
      <el-table-column label="分类ID" align="center" prop="classification" />
      <el-table-column label="地址" align="center" prop="address" width="200px" />
      <el-table-column label="助力人数" align="center" prop="assistNumber" />
      <el-table-column label="评分" align="center" prop="score" />
      <el-table-column label="评分等级" align="center" prop="grade" />
      <el-table-column label="人均消费" align="center" prop="perCapita" />
      <el-table-column label="操作" align="center" class-name="small-padding fixed-width">
        <template #default="scope">
          <el-button link type="primary" icon="Edit" @click="review(scope.row)" v-hasPermi="['ds:store:edit']"
            v-if="scope.row.toExamine === 1">
            审核
          </el-button>

          <el-button link type="primary" icon="Edit" @click="addScore(scope.row)" v-hasPermi="['ds:store:edit']"
            v-if="scope.row.toExamine === 2">
            增加暗访
          </el-button>

          <el-button link type="primary" icon="Edit" @click="handleUpdate(scope.row)"
            v-hasPermi="['ds:store:edit']">修改</el-button>
          <el-button link type="primary" icon="Delete" @click="handleDelete(scope.row)"
            v-hasPermi="['ds:store:remove']">删除</el-button>
        </template>
      </el-table-column>
    </el-table>

    <pagination v-show="total > 0" :total="total" v-model:page="queryParams.pageNum"
      v-model:limit="queryParams.pageSize" @pagination="getList" />

    <el-dialog title="暗访" v-model="visitShow" width="500px" append-to-body>
      <el-form ref="visitRef" :model="visitForm" label-width="100px" style="height: 750px; overflow-y: auto">
        <el-form-item label="综合评分" prop="comprehensiveScore">
          <el-input-number :min="0" :max="10" v-model="visitForm.comprehensiveScore" placeholder="请输入综合评分" />
        </el-form-item>
        <el-form-item label="位置便利度" prop="position">
          <el-input-number :min="0" :max="10" v-model="visitForm.position" placeholder="请输入位置便利度" />
        </el-form-item>
        <el-form-item label="环境评分" prop="environment">
          <el-input-number :min="0" :max="10" v-model="visitForm.environment" placeholder="请输入环境评分" />
        </el-form-item>

        <el-form-item label="服务质量" prop="qualityService">
          <el-input-number :min="0" :max="10" v-model="visitForm.qualityService" placeholder="请输入服务质量" />
        </el-form-item>

        <el-form-item label="菜品品质" prop="qualityDishes">
          <el-input-number :min="0" :max="10" v-model="visitForm.qualityDishes" placeholder="请输入菜品品质" />
        </el-form-item>

        <el-form-item label="性价比" prop="costEffectiveness">
          <el-input-number :min="0" :max="10" v-model="visitForm.costEffectiveness" placeholder="请输入性价比" />
        </el-form-item>

        <el-form-item label="综合评价" prop="comprehensiveEvaluation">
          <el-input type="textarea" v-model="visitForm.comprehensiveEvaluation" placeholder="请输入综合评价" />
        </el-form-item>
        <!-- 双值 -->
        <el-form-item label="店面卫生" prop="storeHygiene">
          <el-space direction="vertical" alignment="start">
            <el-input-number :min="0" :max="10" v-model="visitForm.storeHygiene.score" placeholder="请输入店面卫生评分" />

            <el-input type="textarea" v-model="visitForm.storeHygiene.comment" placeholder="请输入店面卫生备注"></el-input>
          </el-space>
        </el-form-item>

        <el-form-item label="座位舒适度" prop="seatComfort">
          <el-space direction="vertical" alignment="start">
            <el-input-number :min="0" :max="10" v-model="visitForm.seatComfort.score" placeholder="请输入座位舒适度分数" />
            <el-input type="textarea" v-model="visitForm.seatComfort.comment" placeholder="请输入座位舒适度备注" />
          </el-space>
        </el-form-item>

        <el-form-item label="噪音水平" prop="noiseLevel">
          <el-space direction="vertical" alignment="start">
            <el-input-number :min="0" :max="10" v-model="visitForm.noiseLevel.score" placeholder="请输入噪音水平分数" />
            <el-input type="textarea" v-model="visitForm.noiseLevel.comment" placeholder="请输入噪音水平备注" />
          </el-space>
        </el-form-item>

        <el-form-item label="服务态度" prop="serviceAttitude">
          <el-space direction="vertical" alignment="start">
            <el-input-number :min="0" :max="10" v-model="visitForm.serviceAttitude.score" placeholder="请输入服务态度分数" />
            <el-input type="textarea" v-model="visitForm.serviceAttitude.comment" placeholder="请输入服务态度备注" />
          </el-space>
        </el-form-item>

        <el-form-item label="上菜速度" prop="serviceSpeed">
          <el-space direction="vertical" alignment="start">
            <el-input-number :min="0" :max="10" v-model="visitForm.serviceSpeed.score" placeholder="请输入上菜速度分数" />
            <el-input type="textarea" v-model="visitForm.serviceSpeed.comment" placeholder="请输入上菜速度备注" />
          </el-space>
        </el-form-item>

        <el-form-item label="投诉处理" prop="complaints">
          <el-space direction="vertical" alignment="start">
            <el-input-number :min="0" :max="10" v-model="visitForm.complaints.score" placeholder="请输入投诉处理分数" />
            <el-input type="textarea" v-model="visitForm.complaints.comment" placeholder="请输入投诉处理备注" />
          </el-space>
        </el-form-item>

        <el-form-item label="暗访时间" prop="addTime">
          <el-date-picker v-model="visitForm.addTime" type="date" placeholder="请输入暗访时间" value-format="YYYY-MM-DD" />
        </el-form-item>

        <el-form-item label="暗访人员 " prop="staff">
          <el-input v-model="visitForm.staff" placeholder="请输入暗访人员" />
        </el-form-item>

        <el-form-item label="暗访图片" prop="darkImage">
          <image-upload v-model="visitForm.darkImage"></image-upload>
        </el-form-item>
      </el-form>
      <template #footer>
        <div class="dialog-footer">
          <el-button type="primary" @click="submitVisitForm">确 定</el-button>
          <el-button @click="cancelVisit">取 消</el-button>
        </div>
      </template>
    </el-dialog>

    <!-- 添加或修改入驻商家对话框 -->
    <el-dialog :title="title" v-model="open" width="500px" append-to-body>
      <el-form ref="storeRef" :model="form" :rules="rules" label-width="80px">
        <el-form-item label="店铺名称" prop="name">
          <el-input v-model="form.name" placeholder="请输入店铺名称" />
        </el-form-item>
        <el-form-item label="店铺图片" prop="picture">
          <image-upload v-model="form.picture" :limit="10" />
        </el-form-item>
        <el-form-item label="店铺简介" prop="details">
          <Editor v-model="form.details" placeholder="请输入店铺简介" :minHeight="300"></Editor>
        </el-form-item>
        <el-form-item label="手机号" prop="telephone">
          <el-input v-model="form.telephone" placeholder="请输入手机号" />
        </el-form-item>
        <el-form-item label="法人" prop="legalPerson">
          <el-input v-model="form.legalPerson" placeholder="请输入法人" />
        </el-form-item>
        <el-form-item label="法人身份证正面" prop="frontIdCard">
          <image-upload v-model="form.frontIdCard" />
        </el-form-item>
        <el-form-item label="法人身份证反面" prop="reverseIdCard">
          <image-upload v-model="form.reverseIdCard" />
        </el-form-item>
        <el-form-item label="用户ID" prop="uid">
          <el-input v-model="form.uid" placeholder="请输入用户ID" />
        </el-form-item>
        <el-form-item label="分类ID" prop="classification">
          <el-select placeholder="请选择父分类" v-model="form.classification" clearable @keyup.enter="handleQuery">
            <el-option value="0" label="全部"></el-option>
            <!-- 所有分类 -->
            <el-option v-for="item in allCategoryList" :key="item.id" :label="item.cateName"
              :value="`${item.id}`"></el-option>
          </el-select>
        </el-form-item>
        <el-form-item label="备注" prop="remarks">
          <el-input v-model="form.remarks" placeholder="请输入备注" />
        </el-form-item>
        <el-form-item label="营业执照" prop="businessLicense">
          <image-upload v-model="form.businessLicense" />
        </el-form-item>
        <el-form-item label="地址" prop="address" >
          <!--  -->
          <ProvinceCityCounty v-model="provinceCityCounty" />
          <el-input v-model="address" placeholder="请输入详细地址" @blur="handleGetLocation" />
          <span>{{ form.longitude }},{{ form.dimension }}</span>
        </el-form-item>

        <el-form-item label="位置地图" v-if="form.longitude && form.dimension">
          <div id="map-container" style="width: 100%; height: 300px"></div>
        </el-form-item>
        <el-form-item label="助力人数" prop="assistNumber">
          <el-input v-model="form.assistNumber" placeholder="请输入助力人数" />
        </el-form-item>
        <el-form-item label="评分" prop="score">
          <el-input v-model="form.score" placeholder="请输入评分" />
        </el-form-item>
        <el-form-item label="标签" prop="label">
          <el-input v-model="form.label" placeholder="请输入标签" />
        </el-form-item>
        <el-form-item label="评分等级" prop="grade">
          <el-select v-model="form.grade" placeholder="请选择评分等级">
            <el-option label="优" value="优"></el-option>
            <el-option label="良" value="良"></el-option>
            <el-option label="中" value="中"></el-option>
            <el-option label="及格" value="及格"></el-option>
          </el-select>
        </el-form-item>
        <el-form-item label="人均消费" prop="perCapita">
          <el-input v-model="form.perCapita" placeholder="请输入人均消费" />
        </el-form-item>
      </el-form>
      <template #footer>
        <div class="dialog-footer">
          <el-button type="primary" @click="submitForm">确 定</el-button>
          <el-button @click="cancel">取 消</el-button>
        </div>
      </template>
    </el-dialog>
  </div>
</template>

<script setup name="Store">
import { listStore, getStore, delStore, addStore, updateStore, addVisit, listVisit } from "@/api/ds/store";
import { listCategory } from "@/api/ds/category";
import axios from "axios";
import ProvinceCityCounty from "@/components/provinceCityCounty.vue";

import AMapLoader from "@amap/amap-jsapi-loader";

const map = ref(null);

const { proxy } = getCurrentInstance();

const storeList = ref([]);
const open = ref(false);
const loading = ref(true);
const showSearch = ref(true);
const ids = ref([]);
const single = ref(true);
const multiple = ref(true);
const total = ref(0);
const title = ref("");

const address = ref("");
const provinceCityCounty = ref([]);

const data = reactive({
  form: {},
  queryParams: {
    pageNum: 1,
    pageSize: 10,
    name: null,
    picture: null,
    details: null,
    telephone: null,
    legalPerson: null,
    frontIdCard: null,
    reverseIdCard: null,
    uid: null,
    toExamine: null,
    status: null,
    reason: null,
    balance: null,
    classification: null,
    remarks: null,
    businessLicense: null,
    address: null,
    source: null,
    realName: null,
    idCard: null,
    bankName: null,
    bankNo: null,
    longitude: null,
    dimension: null,
    assistNumber: null,
    score: null,
    label: null,
    report: null,
    darkImage: null,
    grade: null,
    perCapita: null,
  },
  rules: {},
});

const { queryParams, form, rules } = toRefs(data);

/** 查询入驻商家列表 */
function getList() {
  loading.value = true;
  listStore(queryParams.value).then((response) => {
    storeList.value = response.rows;
    total.value = response.total;
    loading.value = false;
  });
}

// 初始化地图
const initMap = () => {
  AMapLoader.load({
    key: "fbacb26edf56429309b33c7ed0e37d0b", // 您的高德地图key
    version: "2.0",
    plugins: ["AMap.Marker"],
  })
    .then((AMap) => {
      map.value = new AMap.Map("map-container", {
        zoom: 15, // 缩放级别
        center: [form.value.longitude, form.value.dimension], // 中心点坐标
      });

      // 添加标准图层
      const tileLayer = new AMap.TileLayer({
        zIndex: 10,
      });
      map.value.add(tileLayer);

      // 添加标记点
      new AMap.Marker({
        position: new AMap.LngLat(form.value.longitude, form.value.dimension),
        map: map.value,
      });
    })
    .catch((e) => {
      console.error(e);
    });
};

const handleGetLocation = async () => {
  console.log("handleGetLocation");
  // 获取经纬度
  const key = "fbacb26edf56429309b33c7ed0e37d0b";

  // 判断地址
  let resp = await axios({
    url: `https://restapi.amap.com/v3/geocode/geo?key=${key}&address=${address.value}`,
    method: "GET",
  });

  console.log("resp", resp);

  if (resp.data.status == 1) {
    let location = resp.data.geocodes[0].location;
    form.value.longitude = location.split(",")[0];
    form.value.dimension = location.split(",")[1];

    // 初始化地图
    nextTick(() => {
      initMap();
    });
  } else {
    proxy.$modal.msgSuccess("定位获取失败");
    return;
  }
};

// 取消按钮
function cancel() {
  open.value = false;
  reset();
}

// 表单重置
function reset() {
  form.value = {
    id: null,
    name: null,
    picture: null,
    details: null,
    telephone: null,
    legalPerson: null,
    frontIdCard: null,
    reverseIdCard: null,
    uid: null,
    toExamine: null,
    status: null,
    reason: null,
    balance: null,
    createTime: null,
    classification: null,
    remarks: null,
    businessLicense: null,
    address: null,
    source: null,
    realName: null,
    idCard: null,
    bankName: null,
    bankNo: null,
    longitude: null,
    dimension: null,
    assistNumber: null,
    score: null,
    label: null,
    report: null,
    darkImage: null,
    grade: null,
    perCapita: null,
  };
  proxy.resetForm("storeRef");
}

/** 搜索按钮操作 */
function handleQuery() {
  queryParams.value.pageNum = 1;
  getList();
}

const visitForm = reactive({
  comprehensiveScore: "",
  position: "",
  environment: "",
  qualityService: "",
  qualityDishes: "",
  costEffectiveness: "",
  comprehensiveEvaluation: "",
  // --双值--
  storeHygiene: { score: "", comment: "" },
  seatComfort: { score: "", comment: "" },
  noiseLevel: { score: "", comment: "" },
  serviceAttitude: { score: "", comment: "" },
  serviceSpeed: { score: "", comment: "" },
  complaints: { score: "", comment: "" },
  // ------
  addTime: "",
  staff: "",
  darkImage: "",

  storeId: "",
});

const visitShow = ref(false);

async function addScore(row) {
  visitForm.storeId = row.id;

  // 查询店铺的暗访记录
  let res = await listVisit({ storeId: row.id });
  if (res.code == 200) {
    if (res.rows.length > 0) {
      let visit = res.rows[0];
      visitForm.addTime = visit.addTime || 0;
      visitForm.staff = visit.staff || 0;
      visitForm.darkImage = visit.darkImage || 0;
      visitForm.comprehensiveScore = visit.comprehensiveScore || 0;
      visitForm.position = visit.position || 0;
      visitForm.environment = visit.environment || 0;
      visitForm.qualityService = visit.qualityService || 0;
      visitForm.qualityDishes = visit.qualityDishes || 0;
      visitForm.costEffectiveness = visit.costEffectiveness || 0;
      visitForm.comprehensiveEvaluation = visit.comprehensiveEvaluation || 0;

      visitForm.storeHygiene = JSON.parse(visit.storeHygiene) || {
        score: 0,
        comment: "",
      };
      visitForm.seatComfort = JSON.parse(visit.seatComfort) || {
        score: 0,
        comment: "",
      };
      visitForm.noiseLevel = JSON.parse(visit.noiseLevel) || {
        score: 0,
        comment: "",
      };
      visitForm.serviceAttitude = JSON.parse(visit.serviceAttitude) || {
        score: 0,
        comment: "",
      };
      visitForm.serviceSpeed = JSON.parse(visit.serviceSpeed) || {
        score: 0,
        comment: "",
      };
      visitForm.complaints = JSON.parse(visit.complaints) || {
        score: 0,
        comment: "",
      };
    }
  }
  // 增加暗访表单展示
  visitShow.value = true;
}

async function submitVisitForm() {
  let data = {
    storeId: visitForm.storeId,
    addTime: visitForm.addTime,
    staff: visitForm.staff,
    darkImage: visitForm.darkImage,
    comprehensiveScore: visitForm.comprehensiveScore,
    position: visitForm.position,
    environment: visitForm.environment,
    qualityService: visitForm.qualityService,
    qualityDishes: visitForm.qualityDishes,
    costEffectiveness: visitForm.costEffectiveness,
    comprehensiveEvaluation: visitForm.comprehensiveEvaluation,

    storeHygiene: JSON.stringify(visitForm.storeHygiene),
    seatComfort: JSON.stringify(visitForm.seatComfort),
    noiseLevel: JSON.stringify(visitForm.noiseLevel),
    serviceAttitude: JSON.stringify(visitForm.serviceAttitude),
    serviceSpeed: JSON.stringify(visitForm.serviceSpeed),
    complaints: JSON.stringify(visitForm.complaints),
  };

  let res = await addVisit(data);

  if (res.code == 200) {
    proxy.$modal.msgSuccess("添加成功");
    visitShow.value = false;
    getList();
  }
}

function cancelVisit() {
  visitShow.value = false;
}

/** 重置按钮操作 */
function resetQuery() {
  proxy.resetForm("queryRef");
  handleQuery();
}

// 多选框选中数据
function handleSelectionChange(selection) {
  ids.value = selection.map((item) => item.id);
  single.value = selection.length != 1;
  multiple.value = !selection.length;
}

/** 新增按钮操作 */
function handleAdd() {
  reset();
  open.value = true;
  title.value = "添加入驻商家";

  provinceCityCounty.value = ["江西省", "上饶市", "信州区"];
  address.value = "";

  nextTick(() => {
    initMap();
  });
}

/** 修改按钮操作 */
function handleUpdate(row) {
  reset();
  const _id = row.id || ids.value;
  getStore(_id).then((response) => {
    form.value = response.data;

    console.log("form.value.address", form.value.address);

    let arr = form.value.address.split(" ");

    if (arr.length > 1) {
      provinceCityCounty.value = arr[0].split("-");
      address.value = arr[1];
    } else {
      provinceCityCounty.value = ["江西省", "上饶市", "信州区"];
      address.value = arr[0];
    }

    open.value = true;
    title.value = "修改入驻商家";

    nextTick(() => {
      initMap();
    });
  });
}

/** 提交按钮 */
function submitForm() {
  proxy.$refs["storeRef"].validate((valid) => {
    if (valid) {
      if (form.value.id != null) {
        if (!form.value.longitude || !form.value.dimension) {
          proxy.$modal.alertError("请设置正确的地址定位");

          return;
        }

        updateStore({ ...form.value, address: provinceCityCounty.value.join("-") + " " + address.value }).then((response) => {
          proxy.$modal.msgSuccess("修改成功");
          open.value = false;
          getList();
        });
      } else {
        if (!form.value.longitude || !form.value.dimension) {
          proxy.$modal.alertError("请设置正确的地址定位");

          return;
        }

        addStore({ ...form.value, address: provinceCityCounty.value.join("-") + " " + address.value }).then((response) => {
          proxy.$modal.msgSuccess("新增成功");
          open.value = false;
          getList();
        });
      }
    }
  });
}

function review(row) {
  const _ids = row.id || ids.value;

  proxy.$modal
    .confirm('是否确认通过商家编号为"' + _ids + '"的入驻审核？', "通过", "不通过")
    .then(function () {
      updateStore({ ...row, toExamine: 2 }).then((response) => {
        proxy.$modal.msgSuccess("审核通过成功");
        open.value = false;
        getList();
      });
    })
    .catch(() => {
      proxy.$modal.prompt("请输入审核失败原因", "不通过", "取消").then(({ value }) => {
        updateStore({ ...row, toExamine: 3, reason: value }).then((response) => {
          proxy.$modal.msgSuccess("审核不通过");
          open.value = false;
          getList();
        });
      });
    });
}

/** 删除按钮操作 */
function handleDelete(row) {
  const _ids = row.id || ids.value;
  proxy.$modal
    .confirm('是否确认删除入驻商家编号为"' + _ids + '"的数据项？')
    .then(function () {
      return delStore(_ids);
    })
    .then(() => {
      getList();
      proxy.$modal.msgSuccess("删除成功");
    })
    .catch(() => { });
}

/** 导出按钮操作 */
function handleExport() {
  proxy.download(
    "ds/store/export",
    {
      ...queryParams.value,
    },
    `store_${new Date().getTime()}.xlsx`
  );
}

getList();

const allCategoryList = ref([]);

const initAllCategory = async () => {
  let res = await listCategory();
  if (res.code == 200) {
    allCategoryList.value = res.rows;
  }
};

initAllCategory();
</script>
